package com.example.demo.dao;

import com.example.demo.bean.Message;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MessageDao {

    /*查询*/
    @Select("SELECT * FROM message WHERE Hospital = #{Hospital}")
    List<Message> Message(String hospital);

    /*新增*/
    @Insert("insert into message (Hospital,Patient,State,Record,name) values (#{Hospital}, #{Patient}, #{State},#{Record},#{name})")
    void insert(Message message);

    /*删除*/
    @Delete("DELETE FROM message WHERE Hospital = #{Hospital}")
    void delete(String Hospital);

    /*修改数据*/
    @Update("UPDATE message SET Patient = #{Patient},State = #{State},Record = #{Record},name = #{name} WHERE Hospital = #{Hospital}")
    void update(Message message);

    @Select("SELECT\n" +
            "\ts.department1,\n" +
            "\tt.Hospital,\n" +
            "\tt.Patient,\n" +
            "\tt.State,\n" +
            "\tt.record,\n" +
            "\tt.`name`,\n" +
            "\tt.old,\n" +
            "  t.id,\n" +
            "tt.operation,tt.time1,\n" +
            "w.warehouse,w.Shelf\n" +
            "FROM\n" +
            "\tmessage t\n" +
            "JOIN dmt ts ON t.id = ts.d_id\n" +
            "JOIN department s ON s.d_id = ts.d_id\n" +
            "JOIN timeaxis tt ON  tt.t_id = ts.t_id\n" +
            "JOIN warehouse w ON  w.w_id = ts.t_id\n" +
            "WHERE\n" +
            "\tt.Hospital = #{Hospital}"
    )
    List<Message> sel(String Hospital);
}
